// services/summaryService.js
import {hostAddr} from '@/config.js';

export async function saveSummary(chatId, languageUseSummary, pronunciationSummary, communicationSkillSummary) {
  const url = `${hostAddr}/summary/${chatId}`;
  const response = await fetch(url, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      chat_id: chatId,
      language_use_analysis: languageUseSummary,
      pronunciation_analysis: pronunciationSummary,
      communication_skill_analysis: communicationSkillSummary,
    }),
  });

  if (!response.ok) throw new Error('Failed to save summary');
  return await response.json();
}